package com.avhdeveloper.interceptors;

import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;

import com.avhdeveloper.utils.Assert;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;



public class ReferenceDataInterceptor extends AbstractInterceptor{

  private static final long serialVersionUID = 1L;
  

  @Override
  public String intercept(ActionInvocation invocation) throws Exception {
    Map<String, Object> application = invocation.getInvocationContext().getApplication();
    System.out.println("The current locale is " + invocation.getInvocationContext().getLocale());
    Assert.notNull(application);
    System.out.println("this is the fetched object " + application.get("options"));
    application.put("options", Arrays.asList(new String[]{"one", "two", "three"}));
    System.out.println("done setting the list, value is now " + application.get("options"));
    // trachten van het op de valuestack te gooien, application blijkt niet te werken.
    // om ��n of andere reden kan je in de jsp niet #application.options gebruiken --> copieren naar de vs. 
    invocation.getInvocationContext().getValueStack().set("options", application.get("options"));
    return invocation.invoke();
  }
}
